<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body>
	<form class="layui-form" action="" lay-filter="user-reset-pwd-form" style="margin-top: 20px;">
		<div class="layui-form-item">
			<label class="layui-form-label">旧密码：</label>
			<div class="layui-input-block">
				<input name="pwdOld" type="password" placeholder="请输入旧密码" autocomplete="off" class="layui-input"
					lay-verify="required">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">新密码：</label>
			<div class="layui-input-block">
				<input name="pwdNew" type="password" placeholder="请输入新密码" autocomplete="off" class="layui-input"
					lay-verify="required">
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn" lay-submit="" lay-filter="user-reset-pwd">修改密码</button>
			</div>
		</div>
	</form>
	<div th:include="include::footer"></div>
	<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
	<script>
		layui.use([ 'layer', 'jquery', 'form' ], function() {
			var $ = layui.jquery;
			var layer = layui.layer;
			var form = layui.form;

			//监听提交
			form.on('submit(user-reset-pwd)', function(data) {
				//提交数据data.field
				$.ajax({
					cache : true,
					type : "POST",
					url : "/sys/user/resetPwd",
					data : data.field,
					async : false,
					error : function(request) {
						layer.alert("Connection error");
					},
					success : function(r) {
						if (r.retCode == '0000') {
							parent.layer.msg("保存成功");
							var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
							parent.layer.close(index);
						} else {
							layer.msg(r.retMsg, {
								icon : 1,
								time : 1000
							//2秒关闭（如果不配置，默认是3秒）
							}, function() {
								var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
								parent.layer.close(index);
							});

						}
					}
				});
				return false;
			});
		});
	</script>
</body>
</html>